package fpt.edu.vn.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import fpt.edu.vn.dao.UsersDao;
import fpt.edu.vn.model.Topics;

/* 
 * ViewUserProfileAction.java
 *  
 * 0.1
 * 
 * 10/15/2012 
 *  
 * Copyright notice 
 *  
 * Modification Logs: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  -------------------------------------------------------- 
 *  15-Oct-2012  ThuongND    Create new 
 */
public class ViewUserProfileAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int user_Id;
	Map<String, Object> session;
	private List<Topics> topics;
	private List<Object> users;
	private List<Topics> ownerTopics;
	private List<Topics> ownerFavorite;
	private UsersDao dao = new UsersDao();

	public String execute() {

		session = ActionContext.getContext().getSession();
		int userIdfromss = 0;
		if (session.containsKey("userIdss")) {
			userIdfromss = (Integer) session.get("userIdss");
		}
		if (userIdfromss == user_Id) {
			return SUCCESS;
		} else {

			this.topics = dao.countNumberPost(user_Id);
			users = dao.listProfile(user_Id);
			this.ownerTopics = dao.listOwnerTopic(user_Id);
			this.ownerFavorite = dao.listOwnerFavorite(user_Id);
			return NONE;
		}

	}

	public int getUser_Id() {
		return user_Id;
	}

	public void setUser_Id(int user_Id) {
		this.user_Id = user_Id;
	}

	public List<Object> getUsers() {
		return users;
	}

	public void setUsers(List<Object> users) {
		this.users = users;
	}

	public List<Topics> getOwnerTopics() {
		return ownerTopics;
	}

	public void setOwnerTopics(List<Topics> ownerTopics) {
		this.ownerTopics = ownerTopics;
	}

	public List<Topics> getOwnerFavorite() {
		return ownerFavorite;
	}

	public void setOwnerFavorite(List<Topics> ownerFavorite) {
		this.ownerFavorite = ownerFavorite;
	}

	public List<Topics> getTopics() {
		return topics;
	}

	public void setTopics(List<Topics> topics) {
		this.topics = topics;
	}
	

}
